{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>用户列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->
            <!-- <div class="row">
                <div class="col-sm-12">
                    <form name="admin_list_sea" class="form-search" method="post" action="{:url('index')}">
                        <div class="col-sm-3">
                            <div class="input-group">
                                <input type="text" id="key" class="form-control" name="key" placeholder="输入需查询的用户名" />
                                <span class="input-group-btn">
                                    <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
                                </span>
                            </div>
                        </div>
                    </form>
                </div>
            </div> -->
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
                                <th>ID</th>
                                <th>电话</th>
                                <th>昵称</th>
                                <th>真实姓名</th>
                                <th>介绍</th>
                                <th>qq</th>
                                <th>地址</th>
                                <th>加入时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody id="list-content">
                          {volist name="data.applys" id="vo"}
                              <tr class="long-td">
                                  <td>{$vo.id}</td>
                                  <td>{$vo.mobile}</td>
                                  <td>{$vo.username}</td>
                                  <td>{$vo.name}</td>
                                  <td>{$vo.present}</td>
                                  <td>{$vo.qq}</td>
                                  <td>{$vo.address}</td>
                                  <td>{$vo.add_time|date="Y-m-d H:i:s",###}</td>
                                  <td>
                                      <a href="javascript:;" class="btn btn-primary btn-xs" onclick="aaa({$vo.id})" data-toggle="modal" data-target="#myModal" ><i class="fa fa-paste"></i> 同意</a>&nbsp;&nbsp;
                                      <a href="javascript:;" onclick="examineApply({$vo.id},3)" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> 拒绝</a>
                                  </td>
                              </tr>
                          {/volist}
                        </tbody>
                    </table>
                    {$data.page}
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>
{include file="public/footer" /}
<div class="modal  fade" id="myModal" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h3 class="modal-title">选择商户类型</h3>
            </div>
            <form class="form-horizontal" name="add_rule" id="add_rule" method="post" action="{:url('examineApply')}">
                <input type="hidden" name="seller_id">
                <input type="hidden" name="status" value="2">
                <div class="ibox-content">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">选择商户类型</label>
                        <div class="col-sm-8">
                            <select name="seller_type_id" class="form-control">
                                <option value="0">--请选择商户类型--</option>
                                {volist name="data.sellerTypes" id="vo"}
                                <option value="{$vo.id}" style="margin-left:55px;">{$vo.name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="hr-line-dashed"></div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> 保存</button>
                    <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-close"></i> 关闭</button>
                </div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    var aaa=function(id){
        $('input[name="seller_id"]').val(id);
    }

    $(function(){
        $('#add_rule').ajaxForm({
            beforeSubmit: checkForm,
            success: complete,
            dataType: 'json'
        });

        function checkForm(){
            if( 0 == $.trim($('select[name="seller_type_id"]').val())){
                layer.msg('请选择商户类型',{icon:2,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }
        }

        function complete(data){
            if(data.code==1){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    window.location.href="{:url('applys')}";
                });
            }else{
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1});
                return false;
            }
        }
    })

    function examineApply(id,status){
        var index = layer.confirm('拒绝该申请？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post('{:url("examineApply")}',{'seller_id':id,'status':status},function(data){
                console.log(data);
                if(data.code == 1){
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 2000,
                    },function(){
                        layer.close(index);
                        window.location.reload()
                    });
                }else{
                    layer.msg(data.msg, {
                        icon: 2,
                        time: 2000,
                    },function(){
                        layer.close(index);
                    });
                }
            },'json')
        }, function(){
            layer.close(index);
        });
    }

</script>
</body>
</html>
